﻿using HandyControl.Controls;
using System.Collections.Generic;
using System;
using System.ComponentModel;
using SharpDX;

namespace WpfModelEditor.Core.Controls
{
    public class PropertyEditorCreator : IPropertyEditorCreator
    {
        private static readonly Dictionary<Type, Func<PropertyEditorBase>> TypeCodeDic = new Dictionary<Type, Func<PropertyEditorBase>>
        {
            { typeof(Color4), ()=>new PropertyEditors.Color4Editor() }
        };
        public PropertyEditorBase ResolveEditor(PropertyResolver resolver, PropertyDescriptor propertyDescriptor)
        {
            if (TypeCodeDic.TryGetValue(propertyDescriptor.PropertyType, out var func))
            {
                return func();
            }
            return resolver.ResolveEditor(propertyDescriptor);
        }
    }
}
